{template 'public/header'}
{template 'public/comhead'}
{if $operation == 'post'}
<form class="form-horizontal form" id="form1" action="" method="post" enctype="multipart/form-data">
	<div class="main">
		<div class="panel panel-default">
			<div class="panel-heading">添加考勤设备</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>考勤机位置</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" class="form-control" name="name" value="{$item['name']}" placeholder="填写考勤机位置">
						<div class="help-block">前端显示考勤地点用</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>考勤机类型</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline">
							<input type="radio" value="1" class="printer-type" name="macname"{if $item['macname'] == '1'}checked{/if} id="credit1"> 吉联考勤机
						</label>
						<label class="radio-inline">
							<input type="radio" value="2" class="printer-type" name="macname" {if $item['macname'] == '2'}checked{/if} id="credit2"> 讯贞考勤机
							<span class="label label-success">推荐</span>
						</label>
						<label class="radio-inline">
							<input type="radio" value="3" class="printer-type" name="macname"{if $item['macname'] == '3'}checked{/if} id="credit3"> 优米考勤机
							<span class="label label-success">推荐性价比高</span>
						</label>						
					</div>
				</div>
				<div id="credit-status1" {if $item['macname'] == 2}style="display:block"{else}style="display:none"{/if}>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>广告标题/广告语</label>
						<div class="col-sm-9 col-xs-12">
							<input type="text" class="form-control" name="pop" value="{$banner['pop']}" placeholder="广告标题">
							<div class="help-block">广告标题/广告语</div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>视频链接</label>
						<div class="col-sm-9 col-xs-12">
							<input type="text" class="form-control" name="video" value="{$banner['video']}" placeholder="视频链接">
							<div class="help-block">设备上显示视频，必须为物理地址不支持代码</div>
						</div>
					</div>					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">广告图片1</label>
						<div class="col-sm-9 col-xs-12">
							{php echo tpl_form_field_image('pic1', $banner['pic1'])}
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">广告图片2</label>
						<div class="col-sm-9 col-xs-12">
							{php echo tpl_form_field_image('pic2', $banner['pic2'])}
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">广告图片3</label>
						<div class="col-sm-9 col-xs-12">
							{php echo tpl_form_field_image('pic3', $banner['pic3'])}
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">广告图片4</label>
						<div class="col-sm-9 col-xs-12">
							{php echo tpl_form_field_image('pic4', $banner['pic4'])}
						</div>
					</div>					
				</div>
				<div id="credit-status2" {if $item['macname'] == 3}style="display:block"{else}style="display:none"{/if}>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>滚动公告</label>
						<div class="col-sm-9 col-xs-12">
							<input type="text" class="form-control" name="pop1" value="{$banner['pop']}" placeholder="滚动公告">
							<div class="help-block">显示在待机界面</div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>语音提示</label>
						<div class="col-sm-9 col-xs-12">
							<input type="text" class="form-control" name="VOICEPRE1" value="{$banner['VOICEPRE']}" placeholder="例如：#name#,刷卡成功">
							<div class="help-block">变量名含义，名称：#name# </div>
						</div>
					</div>					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">视频文件</label>
						<div class="col-sm-9 col-xs-12">
							<input type="text" class="form-control" name="video1" value="{$banner['video']}" placeholder="只能填写视频文件名称">
							<div class="help-block">设备上显示视频，必须为物理地址不支持代码，此处地址必须填写文件名，文件储存在{$urls}之下，请手动上传</div>
						</div>
					</div>					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>广告图片1</label>
						<div class="col-sm-9 col-xs-12">
							{php echo tpl_form_field_image('pic11', $banner['pic1'])}
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>广告图片2</label>
						<div class="col-sm-9 col-xs-12">
							{php echo tpl_form_field_image('pic21', $banner['pic2'])}
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>广告图片3</label>
						<div class="col-sm-9 col-xs-12">
							{php echo tpl_form_field_image('pic31', $banner['pic3'])}
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>广告图片4</label>
						<div class="col-sm-9 col-xs-12">
							{php echo tpl_form_field_image('pic41', $banner['pic4'])}
						</div>
					</div>					
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>机器号/设备号</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" class="form-control" name="macid" value="{$item['macid']}" placeholder="填写机器号">
						<div class="help-block">考勤机显示屏上获取/或设备背后</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>进离校区分</label>
					<div class="col-sm-9 col-xs-12">
						<select style="margin-right:15px;" name="type" class="form-control">
                            <option value="0">请选择</option>
                            <option value="1" {if $item['type'] ==1} selected="selected"{/if}>进校设备</option>
							<option value="2" {if $item['type'] ==2} selected="selected"{/if}>离校设备</option>
                        </select>
						<div class="help-block">双机准确判断进校离校/此设置必须添加2台设备来判断/一台选择进校/台选择为离校/不选择则使用考勤设置里的时间来判断进离校，不太准确</div>
					</div>
				</div>				
				{if $_W['isfounder']}
					{if !empty($item['macid'])}
						{if $item['macname'] == 1}
							<div class="form-group">
								<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>设备接口 :</label>
								<div class="col-sm-9 col-xs-12">
									<label class="radio-inline">
										<!-- <a>{php echo $_W['siteroot'] . 'app/index.php?i=' . $item['weid'] . '&c=entry&schoolid=' . $item['schoolid'] . '&do=checkjl&m=fm_jiaoyu'}</a> -->
										<a>{php echo $_W['siteroot'] . 'app/index.php?i=' . $item['weid'] . '&c=entry&schoolid=' . $item['schoolid'] . '&do=checkjl&m=fm_jiaoyu'.'&macid=' . $item['macid'] . ' '}</a>
									<label class="radio-inline">
								</div>
							</div>
						{/if}
						{if $item['macname'] == 2}
							<div class="form-group">
								<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>设备接口 :</label>
								<div class="col-sm-9 col-xs-12">
									<label class="radio-inline">
										<a>{php echo $_W['siteroot'] . 'app/index.php?i=' . $item['weid'] . '&c=entry&schoolid=' . $item['schoolid'] . '&do=checkxz&m=fm_jiaoyu '}</a>
									</label>			
								</div>
							</div>
						{/if}
						{if $item['macname'] == 3}
							<div class="form-group">
								<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>设备接口 :</label>
								<div class="col-sm-9 col-xs-12">
									<label class="radio-inline">
										<a>{php echo $_W['siteroot'] . 'app/index.php?i=' . $item['weid'] . '&c=entry&schoolid=' . $item['schoolid'] . '&do=checkym&m=fm_jiaoyu '}</a>
									</label>			
								</div>
								<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>文件路径 :</label>
								<div class="col-sm-9 col-xs-12">
									<label class="radio-inline">
										<a>{$urls}</a>
									</label>			
								</div>								
							</div>
						{/if}
					{/if}
				{/if}
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-9 col-xs-9 col-md-9">
				<input type="hidden" name="token" value="{$_W['token']}">
				<input name="submit" id="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
			</div>	
		</div>
	</div>
</form>
<script>
$(function(){
	$('#credit1').click(function(){
		$('#credit-status1').hide();
		$('#credit-status2').hide();
	});
	$('#credit2').click(function(){
		$('#credit-status1').show();
		$('#credit-status2').hide();
	});
	$('#credit3').click(function(){
		$('#credit-status2').show();
		$('#credit-status1').hide();
	});	
});
</script>
{elseif $operation == 'display'}
<div class="clearfix">
	<form class="form-horizontal" action="" method="post">
		<div class="form-group">
			<div class="col-sm-12">
				<a class="btn btn-success col-lg-1" href="{php echo $this->createWebUrl('check', array('op' => 'post','schoolid' => $schoolid));}"/><i class="fa fa-plus-circle"> </i>  添加设备</a>
			</div>
		</div>
		<div class="panel panel-default">
			<div class="panel-body table-responsive">
				<table class="table table-hover">
					<thead class="navbar-inner">
						<tr>
							<th>考勤机品牌</th>
							<th>状态</th>
							<th>考勤机名称</th>
							<th>设备判断</th>
							<th>大屏广告</th>
							<th>视频</th>
							<th>机器号</th>
							<th style="width:150px; text-align:right;">状态/修改/删除</th>
						</tr>
					</thead>
					<tbody>
						{loop $list $item}
						<tr>
							<td>
								<span>{if $item['macname'] == '1'}吉联{/if}{if $item['macname'] == '2'}讯贞{/if}{if $item['macname'] == '3'}优米{/if}</span>
							</td>
							<td><input type="checkbox" value="{$item['is_on']}" name="is_on[]" data-id="{$item['id']}" {if $item['is_on'] == 1}checked{/if}></td>
							<td>{$item['name']}</td>
							<td>{if $item['type'] ==1}进校设备{else if $item['type'] ==2}离校设备{else}单机模式{/if}</td>
							<td>
							{if !empty($item['banner'])}
								{if $item['isflow'] == 2}
								<span class="label label-success">已同步</span>					
								{else if $item['isflow'] ==1}
								<span class="label label-danger">未同步</span>
							    {/if}
							{else}
							无
							{/if}
							</td>
							<td>
							{if !empty($item['banner'])}
								{if !empty($item['video'])}
								<span class="label label-success">已设置</span>					
								{else}
								<span class="label label-danger">未设置</span>
							    {/if}
							{else}
							无
							{/if}
							</td>							
							<td>{$item['macid']}</td>
							<td style="text-align:right;">
								<a href="{php echo $this->createWebUrl('check', array('op' => 'post', 'id' => $item['id'], 'schoolid' => $schoolid))}" class="btn btn-default btn-sm" title="编辑" data-toggle="tooltip" data-placement="top" ><i class="fa fa-edit"> </i></a>
								<a href="{php echo $this->createWebUrl('check', array('op' => 'delete', 'id' => $item['id'], 'schoolid' => $schoolid))}" class="btn btn-default btn-sm" title="删除" data-toggle="tooltip" data-placement="top" onclick="if(!confirm('删除后将不可恢复，确定删除吗?')) return false;"><i class="fa fa-times"> </i></a>
							</td>
						</tr>
						{/loop}
					</tbody>
				</table>
			</div>
		</div>
	</form>
</div>
<script type="text/javascript">
require(['jquery.qrcode', 'bootstrap.switch'], function($){

	$(':checkbox[name="is_on[]"]').bootstrapSwitch();
	$(':checkbox[name="is_on[]"]').on('switchChange.bootstrapSwitch', function(e, state){
		var is_on = this.checked ? 1 : 2;
		var id = $(this).data('id');
		$.post("{php echo $this->createWebUrl('check', array('op' => 'change'))}", {is_on: is_on, id: id}, function(resp){
			setTimeout(function(){
				//location.reload();
			}, 500)
		});
	});
});
</script>
{/if}
{template 'public/footer'}